/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Menu.java
 *
 * Created on 23/Nov/2011, 16:30:55
 */
package desint;

import java.awt.CardLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

/**
 *
 * @author lenny
 */
public class MenuSocio extends javax.swing.JPanel {
   
    private int isSelectedPlano;
    private int isSelectedAgenda;
    public JanelaPrincipal janelaprincipal;
    private CardLayout cardlayout;

    /** Creates new form Menu */
    public MenuSocio() {
        initComponents();
        isSelectedPlano=0;
        isSelectedAgenda=0;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        plano = new javax.swing.JLabel();
        agenda = new javax.swing.JLabel();
        background = new javax.swing.JLabel();

        plano.setIcon(new javax.swing.ImageIcon(getClass().getResource("/plano.png"))); // NOI18N
        plano.setToolTipText("Plano de Treinos");
        plano.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        plano.setPreferredSize(new java.awt.Dimension(50, 50));
        plano.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                planoMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                planoMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                planoMousePressed(evt);
            }
        });
        plano.setBounds(20, 20, 60, 60);
        jLayeredPane1.add(plano, javax.swing.JLayeredPane.DEFAULT_LAYER);

        agenda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/agenda_icon.png"))); // NOI18N
        agenda.setToolTipText("Agenda");
        agenda.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        agenda.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                agendaMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                agendaMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                agendaMouseExited(evt);
            }
        });
        agenda.setBounds(20, 110, 50, 50);
        jLayeredPane1.add(agenda, javax.swing.JLayeredPane.DEFAULT_LAYER);

        background.setIcon(new javax.swing.ImageIcon(getClass().getResource("/back_menu.png"))); // NOI18N
        background.setBounds(0, 0, 110, 480);
        jLayeredPane1.add(background, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 481, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void planoMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_planoMouseEntered
        if (isSelectedPlano == 0) {
            ImageIcon icon = new ImageIcon("src/plano_mov.png");
            plano.setIcon(icon);
        }
    }//GEN-LAST:event_planoMouseEntered

    private void planoMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_planoMouseExited
        if (isSelectedPlano == 0) {
            ImageIcon icon = new ImageIcon("src/plano.png");
            plano.setIcon(icon);
        }
    }//GEN-LAST:event_planoMouseExited

    private void planoMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_planoMousePressed
        ImageIcon icon = new ImageIcon("src/plano_sel.png");
        plano.setIcon(icon);
        isSelectedPlano = 1;
        cardlayout = (CardLayout)(janelaprincipal.cardHolder.getLayout());
        cardlayout.show(janelaprincipal.cardHolder, "menuPlano");

        /*    UNSELECT              */
        icon = new ImageIcon("src/agenda_icon.png");
        agenda.setIcon(icon);
        isSelectedAgenda = 0;

    }//GEN-LAST:event_planoMousePressed

    private void agendaMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_agendaMouseEntered
        if (isSelectedAgenda == 0) {
            ImageIcon icon = new ImageIcon("src/agenda_mov.png");
            agenda.setIcon(icon);
        }
    }//GEN-LAST:event_agendaMouseEntered

    private void agendaMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_agendaMouseExited
        if (isSelectedAgenda == 0) {
            ImageIcon icon = new ImageIcon("src/agenda_icon.png");
            agenda.setIcon(icon);
        }
    }//GEN-LAST:event_agendaMouseExited

    private void agendaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_agendaMouseClicked
        ImageIcon icon = new ImageIcon("src/agenda_sel.png");
        agenda.setIcon(icon);
        isSelectedAgenda = 1;
        cardlayout = (CardLayout)(janelaprincipal.cardHolder.getLayout());
        cardlayout.show(janelaprincipal.cardHolder, "menuAgenda");

        /*    UNSELECT              */
        icon = new ImageIcon("src/plano.png");
        plano.setIcon(icon);
        isSelectedPlano = 0;
    }//GEN-LAST:event_agendaMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel agenda;
    private javax.swing.JLabel background;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JLabel plano;
    // End of variables declaration//GEN-END:variables

   
}
